kexec: prefer __copy_to_guest() when possible
authorJan Beulich <jbeulich@suse.com>
Wed, 28 Jan 2015 15:32:01 +0000 (16:32 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 28 Jan 2015 15:32:01 +0000 (16:32 +0100)
It's slightly cheaper and safe as long a copy_from_guest() for the same
guest address range was issued before.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
xen/common/kexec.c

index 05d5de7a758d1982d8fb0be9d858a13ba67a9c4a..3b4275e7365a451cf65bfe176e03445cdc948364 100644 (file)
@@ -662,8 +662,8 @@ static int kexec_get_range(XEN_GUEST_HANDLE_PARAM(void) uarg)
 
     ret = kexec_get_range_internal(&range);
 
-    if ( ret == 0 && unlikely(copy_to_guest(uarg, &range, 1)) )
-        return -EFAULT;
+    if ( ret == 0 && unlikely(__copy_to_guest(uarg, &range, 1)) )
+        ret = -EFAULT;
 
     return ret;
 }
@@ -686,10 +686,11 @@ static int kexec_get_range_compat(XEN_GUEST_HANDLE_PARAM(void) uarg)
     if ( (range.start | range.size) & ~(unsigned long)(~0u) )
         return -ERANGE;
 
-    if ( ret == 0 ) {
+    if ( ret == 0 )
+    {
         XLAT_kexec_range(&compat_range, &range);
-        if ( unlikely(copy_to_guest(uarg, &compat_range, 1)) )
-             return -EFAULT;
+        if ( unlikely(__copy_to_guest(uarg, &compat_range, 1)) )
+             ret = -EFAULT;
     }
 
     return ret;